package top.jiangqiang.qianyi.common.base.service;

import com.baomidou.mybatisplus.core.metadata.TableInfo;
import top.jiangqiang.qianyi.common.base.model.entity.BaseEntity;
import top.jiangqiang.qianyi.common.crypto.EncryptService;

import java.io.Serializable;

/**
 * 用于编写业务
 *
 * @Date 2023/9/22 17:20
 * @Author Jiangqiang
 */
public interface BaseService<S extends BaseDbService<E>, E extends BaseEntity> {
    S getBaseDbService();

    EncryptService getEncryptService();

    default void save(E e) {
        getBaseDbService().save(e);
    }

    default E getById(Serializable id) {
        return getBaseDbService().getById(id);
    }

    default <V> V getById(Serializable id, Class<V> tClass) {
        return getBaseDbService().getById(id, tClass);
    }

    default boolean removeById(E entity) {
        return getBaseDbService().removeById(entity);
    }

    default boolean removeById(Serializable id) {
        return getBaseDbService().removeById(id);
    }

    default boolean updateById(E e) {
        return getBaseDbService().updateById(e);
    }

    default TableInfo getTableInfo() {
        return getBaseDbService().getTableInfo();
    }
}
